package 力扣.位运算.移位运算;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class 可被5整除的二进制前缀1018 {
    public static void main(String[] args) {
//        int[] ints = {0,1,1,1,1,1};//0 1 3 7 15 31
//        int[] ints = {1,0,0,1,0,1,0,0,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,0,0,0,0,1,1,0,1,0,0,0,1};
        int[] ints = {1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,1,0,0,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,0,1,0};
        List<Boolean> booleanList = prefixesDivBy5(ints);
        System.out.println(booleanList);

    }
    public static List<Boolean> prefixesDivBy5(int[] A) {
        ArrayList<Boolean> re = new ArrayList<>();
        int len = A.length;
        int temp=0;
        for (int i = 0; i < len ; i++) {
            temp = temp + A[i];
            temp %=10;//防止数的溢出（只保留个位数，个位数是 0 、5 说明就可以整除 5）
            if (temp % 5 == 0){
                re.add(true);
            }else {
                re.add(false);
            }
//            System.out.println(temp);
            temp = temp << 1;//左移一位

        }
        return re;
    }
}
